<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./PC端公共样式.css">
    <link rel="stylesheet" href="./login.css">
</head>

<body>
    <div class="ucSimpleHeader" id="header">
        <a href="javascript:;">
            PIRACY</a>
    </div>
    <div class="banner-box">
        <div class="container">
            <h1>验证码登录</h1>
            <form action="">
                <input type="text" class="tbx phoneNumber" placeholder="手机号">
                <div class="center">
                    <input type="text" class="tbx code" placeholder="验证码">
                    <button>获取验证码</button>
                </div>
                <input type="submit" class="sub" value="登录">
            </form>
        </div>
    </div>
    <div class="bottom">
        <div class="contain">
            <ul>
                <li> <a href="javascript:;">网站首页</a></li>
                <span>|</span>
                <li><a href="javascript:;">关于我们</a></li>
                <span>|</span>
                <li><a href="javascript:;">产品展示</a></li>
                <span>|</span>
                <li><a href="javascript:;">客户案例</a></li>
                <span>|</span>
                <li><a href="javascript:;">新闻资讯</a></li>
                <span>|</span>
                <li><a href="javascript:;">帮助中心</a></li>
                <span>|</span>
                <li><a href="javascript:;">解决方案</a></li>
                <span>|</span>
                <li><a href="javascript:;">联系我们</a></li>
            </ul>
            <p>Copyright ◎ 2015 -2022 山里的闲人电子有限公司 版权所有 Power by DedeCms</p>
            <p>电话：15997940432 E-mail : 1372606342@qq.com 地址：湖北省武汉市山中区电子城
            </p>
        </div>
    </div>
</body>
<script src="./jquery-3.6.0.min.js"></script>
<script src="./login.js"></script>
<script src="./js_common/AllFunction.js"></script>
<script>
    document.querySelector("button").onclick = function () {
        event.preventDefault();
        let phoneNumber = document.querySelector(".phoneNumber").value;
        let smsCode = document.querySelector('.code');
        let num = 60;
        let that = this
        let timer = setInterval(function () {
            num--;
            if (num >= 0) {
                that.innerText = num + `s重新获取`;
                that.disabled = true;
            } else {
                clearInterval(timer);
                that.innerText = `重新获取`;
                that.disabled = false;
            }
        }, 1000)
        pajax({
            url: 'http://shopapi.phpclub.org.cn:9501/home/sms/send',
            type: 'post',
            contentType: 'application/json',
            data: {
                mobile: phoneNumber,
                scene: 1
            }
        })
        .then(function (response) {
            smsCode.value = response.data.smsCode;
            document.querySelector('.sub').onclick = function () {
                event.preventDefault();
                ajax({
                    url: 'http://shopapi.phpclub.org.cn/home/authorize/mobileLogin',
                    type: 'post',
                    data: {
                        mobile: phoneNumber,
                        code:smsCode.value,
                        appName:'web'
                    },
                    contentType: 'application/json',
                    success: function (response) {
                        location.href='./content.html';
                    }
                })
            }
        })
    }
</script>

</html>